package com.lagou.quartz;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;

import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;

/**
 * @author ascetic
 * @version 1.0
 * @ClassName LoadBalancing
 * @Description TODO
 * @date 2020-07-03 23:53
 */
public class LoadBalancing {


    public static void doJob() throws SchedulerException {

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();


        JobDetail jobDetail1 = newJob(Ackjob.class).withIdentity("ackJob", "group").build();


        //设置触发执行器
        Trigger trigger1 = newTrigger().withIdentity("5secondAck", "group").startNow()
                .withSchedule(simpleSchedule().withIntervalInSeconds(5).repeatForever()).build();


        scheduler.scheduleJob(jobDetail1, trigger1);
        scheduler.start();

    }
}